﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Collections.ObjectModel;

namespace Airport
{
    [Serializable]
    [DataContract]
    [KnownType(typeof(Surface))]
    [KnownType(typeof(Runway))]
    [KnownType(typeof(Taxiway))]
    [KnownType(typeof(Gate))]
    public class Map : IMap 
    {
        private ObservableCollection<Runway> _runways;
        private ObservableCollection<Taxiway> _taxiways;
        private ObservableCollection<Gate> _gates;

        public Map()
        {
            _runways = new ObservableCollection<Runway>();
            _taxiways = new ObservableCollection<Taxiway>();
            _gates = new ObservableCollection<Gate>();
        }

        public Map(ObservableCollection<Runway> runways, ObservableCollection<Taxiway> taxiways, ObservableCollection<Gate> gates)
        {
            _runways = new ObservableCollection<Runway>(runways);
            _taxiways = new ObservableCollection<Taxiway>(taxiways);
            _gates = new ObservableCollection<Gate>(gates);
        }

        public Map(Map previousMap)
        {
            _runways = new ObservableCollection<Runway>(previousMap.Runways);
            _taxiways = new ObservableCollection<Taxiway>(previousMap.Taxiways);
            _gates = new ObservableCollection<Gate>(previousMap.Gates);
        }

        [DataMember]
        public ObservableCollection<Runway> Runways 
        {
            get
            {
                return _runways;
            }

            set
            {
                _runways = value;
            }
        }

        [DataMember]
        public ObservableCollection<Taxiway> Taxiways 
        {
            get
            {
                return _taxiways;
            }

            set
            {
                _taxiways = value;
            }
        }

        [DataMember]
        public ObservableCollection<Gate> Gates
        {
            get
            {
                return _gates;
            }

            set
            {
                _gates = value;
            }
        }

        public void AddRunway(Runway runway)
        {
            _runways.Add(runway);
        }

        public void AddTaxiway(Taxiway taxiway)
        {
            _taxiways.Add(taxiway);
        }

        

    }
}